﻿using KC.DataAccess.Admin;
using KC.DataAccess.Admin.Repository;
using KC.Domain.Core.EFRepository;
using KC.Domain.Core.IRepository;
using KC.Framework.Base;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;

namespace KC.Service.Admin
{
    public static class DependencyInjectUtil
    {
        public static void InjectService(IServiceCollection services)
        {
            services
                //.AddEntityFrameworkSqlServer()
                .AddDbContext<ComAdminContext>(options => options.UseSqlServer(GlobalConfig.DatabaseConnectionString));

            services.AddTransient(typeof(EFUnitOfWorkContextBase), typeof(ComAdminUnitOfWorkContext));

            services.AddScoped(typeof(IDbRepository<>), typeof(CommonEFRepository<>));
            services.AddTransient(typeof(IDbTreeRepository<>), typeof(CommonEFTreeRepository<>));

            services.AddScoped<ITenantUserRepository, TenantUserRepository>();
            services.AddScoped<ITenantUserApplicationRepository, TenantUserApplicationRepository>();
            services.AddScoped<ITenantUserOpenAppErrorLogRepository, TenantUserOpenAppErrorLogRepository>();
            services.AddScoped<ITenantUserOperationLogRepository, TenantUserOperationLogRepository>();

            services.AddTransient<IDatabasePoolService, DatabasePoolService>();
            services.AddTransient<IStoragePoolService, StoragePoolService>();
            services.AddTransient<INoSqlPoolService, NoSqlPoolService>();
            services.AddTransient<IQueuePoolService, QueuePoolService>();
            services.AddTransient<IServiceBusPoolService, ServiceBusPoolService>();

            services.AddTransient<ITenantUserService, TenantUserService>();
        }
    }
}
